package com.zyx;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Tomcat {
    public static void main(String[] args) {
        Tomcat tomcat = new Tomcat();
        tomcat.start();
    }

    public void start() {
        try {

            ExecutorService executorService = Executors.newFixedThreadPool(20);

            ServerSocket serverSocket = new ServerSocket(11112);
            while (true) {
                Socket socket = serverSocket.accept();
                executorService.execute(new SocketProcessor(socket));
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }


}